<?php
namespace Biz\model\designerAward;

use Doraemon\pockets\datebase\BaseDbModel;

class Sign extends BaseDbModel
{
    const _CONFIG_FILE_ = 'db_designer_award';

    const _CONFIG_SELECT_ = 'designer_award';

    const _DATABASE_ = 'biz_designer_award';

    const _TABLE_NAME = 'designer_award_sign';

    //户型 1小户型 2中户型 3大户型
    const USER_HOUSE_SAMLL = 1;
    const USER_HOUSE_MIDDEL = 2;
    const USER_HOUSE_BIG = 3;
    const USER_HOUSE = [
        self::USER_HOUSE_SAMLL => '小户型',
        self::USER_HOUSE_MIDDEL => '中户型',
        self::USER_HOUSE_BIG => '大户型',
    ];
    //未审核、入围、备选、一般、差
    const CHECK_STATUS_UNDONE = 0;
    const CHECK_STATUS_READY = 1;
    const CHECK_STATUS_WAIT = 2;
    const CHECK_STATUS_COMMON = 3;
    const CHECK_STATUS_BAD = 4;
    const CHECK_STATUS_CONFIRM = 5;
    const CHECK_STATUS_MAP = [
        self::CHECK_STATUS_UNDONE   => '未审核',
        self::CHECK_STATUS_READY    => '入围',
        self::CHECK_STATUS_CONFIRM    => '确定入围',
        self::CHECK_STATUS_WAIT     => '备选',
        self::CHECK_STATUS_COMMON   => '一般',
        self::CHECK_STATUS_BAD      => '差',
    ];

    const DESIGNER_AWARD_2019 = 1; //19营造家奖标识

    public static function getAllByWhere($where = [], $files = '*')
    {
        $where = array_merge($where, ['add_time[>]'=>'2019-01-01 01:00:00']);
        $data = self::select($files, $where);
        return $data;
    }

    public static function getOneByWhere($where = [], $files = '*')
    {
        $where = array_merge($where, ['add_time[>]'=>'2019-01-01 01:00:00']);
        $data = self::get($files, $where);
        return $data;
    }

    public static function addData($data)
    {
        try {
            self::insert($data);
            return self::id();
        } catch (Exception $e) {
            return false;
        }
    }

    public static function updateData($data, $where)
    {
        try {
            self::update($data, $where);
            return true;
        } catch (Exception $e) {
            return false;
        }
    }

}